package com.fowo.api.service.handleWork;

import com.fowo.api.model.payable.PayablePayableApproveAction;
import com.fowo.api.model.payable.PayableVo;
import com.fowo.api.service.impl.PayableServiceImpl;
import com.fowo.api.user.model.JwtUserInfo;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import javax.annotation.Resource;

@Component
public class payablePayableApprove implements PayablePayableApproveAction {
    @Resource
    private PayableServiceImpl payableService;


    @Override
    public void run(Long id) throws Exception {
        JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
        PayableVo voById = payableService.getVoById(id);
        Assert.notNull(voById,"不存在");
        Assert.notNull(voById.getSupplierId(),"请选择供应商!");
        Assert.isTrue(voById.getStauts().equals("0"),"违规操作!");
        voById.setStauts("1");
        voById.setVerifier(jwtUserInfo.getUserId());
        payableService.updateById(voById);
    }
}
